import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import main.Application;
import main.DatabaseManager;


public class Main
{	
	private String localPath="";
	
	public static void main(String[] args)
	{					
			Main main = new Main();
			main.localPath=args[0];
			try {
				main.run();
			} catch (Exception e) {
				// 
				e.printStackTrace();
			}
	}
	
	public void run() throws Exception
	{
		ActionListener listener = new AppRunner();		
		DatabaseManager.getInstance().addOKAction(listener);	
		DatabaseManager.getInstance().showChooseWindow(Application.getInstance().getDatabaseConfigFile());
	}
	
	class AppRunner implements ActionListener
	{		
		@Override
		public void actionPerformed(ActionEvent e) 
		{
			try {
				Connection conn = DatabaseManager.getInstance().getConnection();
				DatabaseManager.getInstance().disposeWindow();
				Application.getInstance().run(conn,localPath);
			} catch (Exception e1) 
			{				
				e1.printStackTrace();
			}				
		}
		
	}
}
